package control;

import dao.CommDAO;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUpload;
import org.apache.commons.fileupload.RequestContext;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.fileupload.servlet.ServletRequestContext;
import util.Info;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class MainCtrl extends HttpServlet {

    public MainCtrl() {
        super();
    }

    @Override
    public void destroy() {
        super.destroy(); // Just puts "destroy" string in log
        // Put your code here
    }

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        this.doPost(request, response);
    }

    public void go(String url, HttpServletRequest request, HttpServletResponse response) {
        try {
            request.getRequestDispatcher(url).forward(request, response);
        } catch (ServletException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void gor(String url, HttpServletRequest request, HttpServletResponse response) {
        try {
            response.sendRedirect(url);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

    @Override
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        String ac = request.getParameter("ac");
        if (ac == null) ac = "";
        CommDAO dao = new CommDAO();
        String date = Info.getDateStr();
        String today = date.substring(0, 10);
        String tomonth = date.substring(0, 7);
        HttpSession session = request.getSession();


        if (ac.equals("login")) {
            String pagerandom = request.getParameter("pagerandom") == null ? "" : request.getParameter("pagerandom");
            String random = (String) request.getSession().getAttribute("random");
            if (!pagerandom.equals(random) && request.getParameter("a") != null) {
                request.setAttribute("random", "");
                go("/login.jsp", request, response);
            } else {
                String username = request.getParameter("uname");
                String password = request.getParameter("upass");
                String utype = request.getParameter("utype");
                request.getSession().setAttribute("utype", utype);
                List<HashMap> list = dao
                        .select("select * from sysuser where uname='"
                                + username + "' and status='正常'");
                if (list.size() == 1) {
                    HashMap map = list.get(0);
                    List<HashMap> ulist = dao
                            .select("select * from sysuser where utype='" + utype + "' and uname='"
                                    + username + "' and upass='" + password
                                    + "' and status='正常' ");

                    if (ulist.size() == 1 && password.equals(map.get("upass").toString())) {

                        request.getSession().setAttribute("admin", map);

                        gor("/wallpaper/index.jsp", request, response);

                    } else {
                        request.setAttribute("error", "");
                        go("/login.jsp", request, response);
                    }
                } else {
                    request.setAttribute("error", "");
                    go("/login.jsp", request, response);
                }
            }
        }


        //修改密码
        if (ac.equals("uppass")) {
            String userpass = request.getParameter("upass");
            String copyuserpass = request.getParameter("copyuserpass");
            HashMap user = dao.getmap(Info.getUser(request).get("id").toString(), "sysuser");
            String id = (String) user.get("id");
            String sql = "update sysuser set upass='" + userpass + "' where id=" + id;
            dao.commOper(sql);
            request.setAttribute("suc", "");
            go("/admin/uppass.jsp", request, response);
        }

        //记录竞赛信息
        if (ac.equals("zxksjl")) {
            String generalsrid = request.getParameter("generalsrid");
            String stsname = request.getParameter("stsname");
            String uid = Info.getUser(request).get("id") + "";
            String[] tids = request.getParameterValues("tids");
            for (String t : tids) {
                String sql = "insert into answers values(null,'" + generalsrid + "','" + t + "','" + request.getParameter("m" + t) + "','" + uid + "','" + date + "','','" + stsname + "')";
                dao.commOper(sql);
            }

            HashMap sjmap = dao.select("select * from sts where stsname='" + stsname + "'").get(0);
            String stsids = sjmap.get("stsids").toString();
            for (String str : stsids.split(" ~ ")) {
                String pg = request.getParameter("m" + str) == null ? "0" : request.getParameter("m" + str);
                String a = request.getParameter("a" + str) == null ? "0" : request.getParameter("a" + str);
                if (pg.equals(a)) pg = request.getParameter("f" + str);
                else pg = "0";
                dao.commOper("update answers set total='" + pg + "' where generalsrid='" + generalsrid + "' and tid='" + str + "'");
            }

            request.getSession().setAttribute("suc", "");
            gor("/wallpaper/admin/xsstscx.jsp", request, response);
        }

        if (ac.equals("uploaddoc")) {
            try {
                String filename = "";
                request.setCharacterEncoding("utf-8");
                RequestContext requestContext = new ServletRequestContext(request);
                if (FileUpload.isMultipartContent(requestContext)) {

                    DiskFileItemFactory factory = new DiskFileItemFactory();
                    factory.setRepository(new File(request.getRealPath("/upfile/") + "/"));
                    ServletFileUpload upload = new ServletFileUpload(factory);
                    upload.setSizeMax(100 * 1024 * 1024);
                    List items = new ArrayList();

                    items = upload.parseRequest(request);

                    FileItem fileItem = (FileItem) items.get(0);
                    if (fileItem.getName() != null && fileItem.getSize() != 0) {
                        if (fileItem.getName() != null && fileItem.getSize() != 0) {
                            File fullFile = new File(fileItem.getName());
                            filename = Info.generalFileName(fullFile.getName());
                            File newFile = new File(request.getRealPath("/upfile/") + "/" + filename);
                            try {
                                fileItem.write(newFile);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        } else {
                        }
                    }
                }

                gor("/wallpaper/js/uploaddoc.jsp?docname=" + filename, request, response);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }


        if (ac.equals("uploaddoc2")) {
            try {
                String filename = "";
                request.setCharacterEncoding("utf-8");
                RequestContext requestContext = new ServletRequestContext(request);
                if (FileUpload.isMultipartContent(requestContext)) {

                    DiskFileItemFactory factory = new DiskFileItemFactory();
                    factory.setRepository(new File(request.getRealPath("/upfile/") + "/"));
                    ServletFileUpload upload = new ServletFileUpload(factory);
                    upload.setSizeMax(100 * 1024 * 1024);
                    List items = new ArrayList();

                    items = upload.parseRequest(request);

                    FileItem fileItem = (FileItem) items.get(0);
                    if (fileItem.getName() != null && fileItem.getSize() != 0) {
                        if (fileItem.getName() != null && fileItem.getSize() != 0) {
                            File fullFile = new File(fileItem.getName());
                            filename = Info.generalFileName(fullFile.getName());
                            File newFile = new File(request.getRealPath("/upfile/") + "/" + filename);
                            try {
                                fileItem.write(newFile);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        } else {
                        }
                    }
                }

                go("/wallpaper/js/uploaddoc2.jsp?docname=" + filename, request, response);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }


        if (ac.equals("uploaddoc3")) {
            try {
                String filename = "";
                request.setCharacterEncoding("utf-8");
                RequestContext requestContext = new ServletRequestContext(request);
                if (FileUpload.isMultipartContent(requestContext)) {

                    DiskFileItemFactory factory = new DiskFileItemFactory();
                    factory.setRepository(new File(request.getRealPath("/upfile/") + "/"));
                    ServletFileUpload upload = new ServletFileUpload(factory);
                    upload.setSizeMax(100 * 1024 * 1024);
                    List items = new ArrayList();

                    items = upload.parseRequest(request);

                    FileItem fileItem = (FileItem) items.get(0);
                    if (fileItem.getName() != null && fileItem.getSize() != 0) {
                        if (fileItem.getName() != null && fileItem.getSize() != 0) {
                            File fullFile = new File(fileItem.getName());
                            filename = Info.generalFileName(fullFile.getName());
                            File newFile = new File(request.getRealPath("/upfile/") + "/" + filename);
                            try {
                                fileItem.write(newFile);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        } else {
                        }
                    }
                }

                go("/wallpaper/js/uploaddoc3.jsp?docname=" + filename, request, response);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }

        //导excel
        if (ac.equals("importexcel")) {
            String page = request.getParameter("page");
            String whzdstr = request.getParameter("whzdstr");
            String tablename = request.getParameter("tablename");
            try {
                String filename = "";
                request.setCharacterEncoding("utf-8");
                RequestContext requestContext = new ServletRequestContext(request);
                if (FileUpload.isMultipartContent(requestContext)) {

                    DiskFileItemFactory factory = new DiskFileItemFactory();
                    factory.setRepository(new File(request.getRealPath("/upfile/") + "/"));
                    ServletFileUpload upload = new ServletFileUpload(factory);
                    upload.setSizeMax(100 * 1024 * 1024);
                    List items = new ArrayList();

                    items = upload.parseRequest(request);

                    FileItem fileItem = (FileItem) items.get(0);
                    if (fileItem.getName() != null && fileItem.getSize() != 0) {
                        if (fileItem.getName() != null && fileItem.getSize() != 0) {
                            File fullFile = new File(fileItem.getName());
                            filename = Info.generalFileName(fullFile.getName());
                            File newFile = new File(request.getRealPath("/upfile/") + "/" + filename);
                            try {
                                fileItem.write(newFile);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        } else {
                        }
                    }

                    if (filename.indexOf(".xls") > -1) {
                        Workbook workbook;
                        try {
                            workbook = Workbook.getWorkbook(new File(request.getRealPath("/upfile/") + "/" + filename));
                            //通过Workbook的getSheet方法选择第一个工作簿（从0开始）
                            Sheet sheet = workbook.getSheet(0);
                            //通过Sheet方法的getCell方法选择位置为C2的单元格（两个参数都从0开始）
                            //int empty = 0;
                            for (int i = 1; i < 1000; i++) {
                                Cell cell = null;
                                try {
                                    String isql = "insert into " + tablename + "(";

                                    for (String str : whzdstr.split("-")) {
                                        isql += str + ",";
                                    }
                                    isql = isql.substring(0, isql.length() - 1);
                                    isql += ")values(";

                                    int j = 0;
                                    int empty = 1;
                                    for (String str : whzdstr.split("-")) {
                                        cell = sheet.getCell(j, i);
                                        isql += "'" + cell.getContents() + "',";
                                        String content = cell.getContents() == null ? "" : cell.getContents();
                                        if (!"".equals(content.trim())) {
                                            empty = 0;
                                        }
                                        j++;
                                    }
                                    if (empty == 1) continue;
                                    isql = isql.substring(0, isql.length() - 1);
                                    isql += ")";
                                    dao.commOper(isql);
                                } catch (Exception e) {
                                    continue;
                                }

                            }
                            workbook.close();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
                go("/admin/" + page + "?docname=" + filename, request, response);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }


        if (ac.equals("uploadimg")) {
            try {
                String filename = "";
                request.setCharacterEncoding("utf-8");
                RequestContext requestContext = new ServletRequestContext(request);
                if (FileUpload.isMultipartContent(requestContext)) {

                    DiskFileItemFactory factory = new DiskFileItemFactory();
                    factory.setRepository(new File(request.getRealPath("/upfile/") + "/"));
                    ServletFileUpload upload = new ServletFileUpload(factory);
                    upload.setSizeMax(100 * 1024 * 1024);
                    List items = new ArrayList();

                    items = upload.parseRequest(request);

                    FileItem fileItem = (FileItem) items.get(0);
                    if (fileItem.getName() != null && fileItem.getSize() != 0) {
                        if (fileItem.getName() != null && fileItem.getSize() != 0) {
                            File fullFile = new File(fileItem.getName());
                            filename = Info.generalFileName(fullFile.getName());
                            File newFile = new File(request.getRealPath("/upfile/") + "/" + filename);
                            try {
                                fileItem.write(newFile);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        } else {
                        }
                    }
                }

                go("/js/uploadimg.jsp?filename=" + filename, request, response);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }


        if (ac.equals("uploadimg2")) {
            try {
                String filename = "";
                request.setCharacterEncoding("utf-8");
                RequestContext requestContext = new ServletRequestContext(request);
                if (FileUpload.isMultipartContent(requestContext)) {

                    DiskFileItemFactory factory = new DiskFileItemFactory();
                    factory.setRepository(new File(request.getRealPath("/upfile/") + "/"));
                    ServletFileUpload upload = new ServletFileUpload(factory);
                    upload.setSizeMax(100 * 1024 * 1024);
                    List items = new ArrayList();

                    items = upload.parseRequest(request);

                    FileItem fileItem = (FileItem) items.get(0);
                    if (fileItem.getName() != null && fileItem.getSize() != 0) {
                        if (fileItem.getName() != null && fileItem.getSize() != 0) {
                            File fullFile = new File(fileItem.getName());
                            filename = Info.generalFileName(fullFile.getName());
                            File newFile = new File(request.getRealPath("/upfile/") + "/" + filename);
                            try {
                                fileItem.write(newFile);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        } else {
                        }
                    }
                }

                go("/wallpaper/js/uploadimg2.jsp?filename=" + filename, request, response);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }

        if (ac.equals("uploadimg3")) {
            try {
                String filename = "";
                request.setCharacterEncoding("utf-8");
                RequestContext requestContext = new ServletRequestContext(request);
                if (FileUpload.isMultipartContent(requestContext)) {

                    DiskFileItemFactory factory = new DiskFileItemFactory();
                    factory.setRepository(new File(request.getRealPath("/upfile/") + "/"));
                    ServletFileUpload upload = new ServletFileUpload(factory);
                    upload.setSizeMax(100 * 1024 * 1024);
                    List items = new ArrayList();

                    items = upload.parseRequest(request);

                    FileItem fileItem = (FileItem) items.get(0);
                    if (fileItem.getName() != null && fileItem.getSize() != 0) {
                        if (fileItem.getName() != null && fileItem.getSize() != 0) {
                            File fullFile = new File(fileItem.getName());
                            filename = Info.generalFileName(fullFile.getName());
                            File newFile = new File(request.getRealPath("/upfile/") + "/" + filename);
                            try {
                                fileItem.write(newFile);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        } else {
                        }
                    }
                }

                go("/wallpaper/js/uploadimg3.jsp?filename=" + filename, request, response);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }

        if (ac.equals("uploadimg4")) {
            try {
                String filename = "";
                request.setCharacterEncoding("utf-8");
                RequestContext requestContext = new ServletRequestContext(request);
                if (FileUpload.isMultipartContent(requestContext)) {

                    DiskFileItemFactory factory = new DiskFileItemFactory();
                    factory.setRepository(new File(request.getRealPath("/upfile/") + "/"));
                    ServletFileUpload upload = new ServletFileUpload(factory);
                    upload.setSizeMax(100 * 1024 * 1024);
                    List items = new ArrayList();

                    items = upload.parseRequest(request);

                    FileItem fileItem = (FileItem) items.get(0);
                    if (fileItem.getName() != null && fileItem.getSize() != 0) {
                        if (fileItem.getName() != null && fileItem.getSize() != 0) {
                            File fullFile = new File(fileItem.getName());
                            filename = Info.generalFileName(fullFile.getName());
                            File newFile = new File(request.getRealPath("/upfile/") + "/" + filename);
                            try {
                                fileItem.write(newFile);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        } else {
                        }
                    }
                }

                go("/wallpaper/js/uploadimg4.jsp?filename=" + filename, request, response);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }

        if (ac.equals("uploadimg5")) {
            try {
                String filename = "";
                request.setCharacterEncoding("utf-8");
                RequestContext requestContext = new ServletRequestContext(request);
                if (FileUpload.isMultipartContent(requestContext)) {

                    DiskFileItemFactory factory = new DiskFileItemFactory();
                    factory.setRepository(new File(request.getRealPath("/upfile/") + "/"));
                    ServletFileUpload upload = new ServletFileUpload(factory);
                    upload.setSizeMax(100 * 1024 * 1024);
                    List items = new ArrayList();

                    items = upload.parseRequest(request);

                    FileItem fileItem = (FileItem) items.get(0);
                    if (fileItem.getName() != null && fileItem.getSize() != 0) {
                        if (fileItem.getName() != null && fileItem.getSize() != 0) {
                            File fullFile = new File(fileItem.getName());
                            filename = Info.generalFileName(fullFile.getName());
                            File newFile = new File(request.getRealPath("/upfile/") + "/" + filename);
                            try {
                                fileItem.write(newFile);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        } else {
                        }
                    }
                }

                go("/wallpaper/js/uploadimg5.jsp?filename=" + filename, request, response);
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }


        //regedit.jsp请求处理开始
        if (ac.equals("regedit")) {
            String uname = request.getParameter("uname") == null ? "" : request.getParameter("uname");
            String upass = request.getParameter("upass") == null ? "" : request.getParameter("upass");
            String tname = request.getParameter("tname") == null ? "" : request.getParameter("tname");
            String sfid = request.getParameter("sfid") == null ? "" : request.getParameter("sfid");
            String sex = request.getParameter("sex") == null ? "" : request.getParameter("sex");
            String birth = request.getParameter("birth") == null ? "" : request.getParameter("birth");
            String tel = request.getParameter("tel") == null ? "" : request.getParameter("tel");
            String addrs = request.getParameter("addrs") == null ? "" : request.getParameter("addrs");
            String email = request.getParameter("email") == null ? "" : request.getParameter("email");
            String savetime = date;
            String filename = request.getParameter("filename") == null ? "" : request.getParameter("filename");
            String utype = "会员";
            String status = "新会员";
            String sql = "insert into sysuser(uname,upass,tname,sfid,sex,birth,tel,addrs,email,savetime,filename,utype,status " +
                    ")values('" + uname + "','" + upass + "','" + tname + "','" + sfid + "','" + sex + "','" + birth + "','" + tel + "','" + addrs + "','" + email + "','" + savetime + "','" + filename + "','" + utype + "','" + status + "')";
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/regedit.jsp");
        }
        //regedit.jsp请求处理结束

        //hysysusertj.jsp请求处理开始
        if (ac.equals("hysysusertj")) {
            String uname = request.getParameter("uname") == null ? "" : request.getParameter("uname");
            String upass = request.getParameter("upass") == null ? "" : request.getParameter("upass");
            String tname = request.getParameter("tname") == null ? "" : request.getParameter("tname");
            String sfid = request.getParameter("sfid") == null ? "" : request.getParameter("sfid");
            String sex = request.getParameter("sex") == null ? "" : request.getParameter("sex");
            String birth = request.getParameter("birth") == null ? "" : request.getParameter("birth");
            String tel = request.getParameter("tel") == null ? "" : request.getParameter("tel");
            String addrs = request.getParameter("addrs") == null ? "" : request.getParameter("addrs");
            String email = request.getParameter("email") == null ? "" : request.getParameter("email");
            String savetime = date;
            String filename = request.getParameter("filename") == null ? "" : request.getParameter("filename");
            String utype = "会员";
            String status = "正常";
            String sql = "insert into sysuser(uname,upass,tname,sfid,sex,birth,tel,addrs,email,savetime,filename,utype,status " +
                    ")values('" + uname + "','" + upass + "','" + tname + "','" + sfid + "','" + sex + "','" + birth + "','" + tel + "','" + addrs + "','" + email + "','" + savetime + "','" + filename + "','" + utype + "','" + status + "')";
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/hysysusertj.jsp");
        }
        //hysysusertj.jsp请求处理结束

        //hysysuserxg.jsp请求处理开始
        if (ac.equals("hysysuserxg")) {
            String id = request.getParameter("id");
            String uname = request.getParameter("uname") == null ? "" : request.getParameter("uname");
            String upass = request.getParameter("upass") == null ? "" : request.getParameter("upass");
            String tname = request.getParameter("tname") == null ? "" : request.getParameter("tname");
            String sfid = request.getParameter("sfid") == null ? "" : request.getParameter("sfid");
            String sex = request.getParameter("sex") == null ? "" : request.getParameter("sex");
            String birth = request.getParameter("birth") == null ? "" : request.getParameter("birth");
            String tel = request.getParameter("tel") == null ? "" : request.getParameter("tel");
            String addrs = request.getParameter("addrs") == null ? "" : request.getParameter("addrs");
            String email = request.getParameter("email") == null ? "" : request.getParameter("email");
            String filename = request.getParameter("filename") == null ? "" : request.getParameter("filename");
            String sql = "update sysuser set uname='" + uname + "',upass='" + upass + "',tname='" + tname + "',sfid='" + sfid + "',sex='" + sex + "',birth='" + birth + "',tel='" + tel + "',addrs='" + addrs + "',email='" + email + "',filename='" + filename + "' where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/hysysuserxg.jsp?id=" + id + "");
        }
        //hysysuserxg.jsp请求处理结束

        //sysusertj.jsp请求处理开始
        if (ac.equals("sysusertj")) {
            String uname = request.getParameter("uname") == null ? "" : request.getParameter("uname");
            String upass = request.getParameter("upass") == null ? "" : request.getParameter("upass");
            String tname = request.getParameter("tname") == null ? "" : request.getParameter("tname");
            String sfid = request.getParameter("sfid") == null ? "" : request.getParameter("sfid");
            String sex = request.getParameter("sex") == null ? "" : request.getParameter("sex");
            String birth = request.getParameter("birth") == null ? "" : request.getParameter("birth");
            String tel = request.getParameter("tel") == null ? "" : request.getParameter("tel");
            String addrs = request.getParameter("addrs") == null ? "" : request.getParameter("addrs");
            String email = request.getParameter("email") == null ? "" : request.getParameter("email");
            String savetime = date;
            String filename = request.getParameter("filename") == null ? "" : request.getParameter("filename");
            String utype = "管理员";
            String status = "正常";
            String sql = "insert into sysuser(uname,upass,tname,sfid,sex,birth,tel,addrs,email,savetime,filename,utype,status " +
                    ")values('" + uname + "','" + upass + "','" + tname + "','" + sfid + "','" + sex + "','" + birth + "','" + tel + "','" + addrs + "','" + email + "','" + savetime + "','" + filename + "','" + utype + "','" + status + "')";
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/sysusertj.jsp");
        }
        //sysusertj.jsp请求处理结束

        //sysuserxg.jsp请求处理开始
        if (ac.equals("sysuserxg")) {
            String id = request.getParameter("id");
            String uname = request.getParameter("uname") == null ? "" : request.getParameter("uname");
            String upass = request.getParameter("upass") == null ? "" : request.getParameter("upass");
            String tname = request.getParameter("tname") == null ? "" : request.getParameter("tname");
            String sfid = request.getParameter("sfid") == null ? "" : request.getParameter("sfid");
            String sex = request.getParameter("sex") == null ? "" : request.getParameter("sex");
            String birth = request.getParameter("birth") == null ? "" : request.getParameter("birth");
            String tel = request.getParameter("tel") == null ? "" : request.getParameter("tel");
            String addrs = request.getParameter("addrs") == null ? "" : request.getParameter("addrs");
            String email = request.getParameter("email") == null ? "" : request.getParameter("email");
            String filename = request.getParameter("filename") == null ? "" : request.getParameter("filename");
            String sql = "update sysuser set uname='" + uname + "',upass='" + upass + "',tname='" + tname + "',sfid='" + sfid + "',sex='" + sex + "',birth='" + birth + "',tel='" + tel + "',addrs='" + addrs + "',email='" + email + "',filename='" + filename + "' where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/sysuserxg.jsp?id=" + id + "");
        }
        //sysuserxg.jsp请求处理结束

        //psysuserxg.jsp请求处理开始
        if (ac.equals("psysuserxg")) {
            String id = request.getParameter("id");
            String tname = request.getParameter("tname") == null ? "" : request.getParameter("tname");
            String sfid = request.getParameter("sfid") == null ? "" : request.getParameter("sfid");
            String sex = request.getParameter("sex") == null ? "" : request.getParameter("sex");
            String birth = request.getParameter("birth") == null ? "" : request.getParameter("birth");
            String tel = request.getParameter("tel") == null ? "" : request.getParameter("tel");
            String addrs = request.getParameter("addrs") == null ? "" : request.getParameter("addrs");
            String email = request.getParameter("email") == null ? "" : request.getParameter("email");
            String filename = request.getParameter("filename") == null ? "" : request.getParameter("filename");
            String sql = "update sysuser set tname='" + tname + "',sfid='" + sfid + "',sex='" + sex + "',birth='" + birth + "',tel='" + tel + "',addrs='" + addrs + "',email='" + email + "',filename='" + filename + "' where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/psysuserxg.jsp?id=" + id + "");
        }
        //psysuserxg.jsp请求处理结束

        //mixinfoxg.jsp请求处理开始
        if (ac.equals("mixinfoxg")) {
            String id = request.getParameter("id");
            String content = request.getParameter("content") == null ? "" : request.getParameter("content");
            content = content.replaceAll("'", " ");
            String sql = "update mixinfo set content='" + content + "' where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/mixinfoxg.jsp?id=" + id + "");
        }
        //mixinfoxg.jsp请求处理结束

        //jssysusertj.jsp请求处理开始
        if (ac.equals("jssysusertj")) {
            String uname = request.getParameter("uname") == null ? "" : request.getParameter("uname");
            String upass = request.getParameter("upass") == null ? "" : request.getParameter("upass");
            String tname = request.getParameter("tname") == null ? "" : request.getParameter("tname");
            String sfid = request.getParameter("sfid") == null ? "" : request.getParameter("sfid");
            String sex = request.getParameter("sex") == null ? "" : request.getParameter("sex");
            String birth = request.getParameter("birth") == null ? "" : request.getParameter("birth");
            String tel = request.getParameter("tel") == null ? "" : request.getParameter("tel");
            String addrs = request.getParameter("addrs") == null ? "" : request.getParameter("addrs");
            String email = request.getParameter("email") == null ? "" : request.getParameter("email");
            String savetime = date;
            String filename = request.getParameter("filename") == null ? "" : request.getParameter("filename");
            String utype = "教练";
            String status = "正常";
            String sql = "insert into sysuser(uname,upass,tname,sfid,sex,birth,tel,addrs,email,savetime,filename,utype,status " +
                    ")values('" + uname + "','" + upass + "','" + tname + "','" + sfid + "','" + sex + "','" + birth + "','" + tel + "','" + addrs + "','" + email + "','" + savetime + "','" + filename + "','" + utype + "','" + status + "')";
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/jssysusertj.jsp");
        }
        //jssysusertj.jsp请求处理结束

        //jssysuserxg.jsp请求处理开始
        if (ac.equals("jssysuserxg")) {
            String id = request.getParameter("id");
            String uname = request.getParameter("uname") == null ? "" : request.getParameter("uname");
            String upass = request.getParameter("upass") == null ? "" : request.getParameter("upass");
            String tname = request.getParameter("tname") == null ? "" : request.getParameter("tname");
            String sfid = request.getParameter("sfid") == null ? "" : request.getParameter("sfid");
            String sex = request.getParameter("sex") == null ? "" : request.getParameter("sex");
            String birth = request.getParameter("birth") == null ? "" : request.getParameter("birth");
            String tel = request.getParameter("tel") == null ? "" : request.getParameter("tel");
            String addrs = request.getParameter("addrs") == null ? "" : request.getParameter("addrs");
            String email = request.getParameter("email") == null ? "" : request.getParameter("email");
            String filename = request.getParameter("filename") == null ? "" : request.getParameter("filename");
            String sql = "update sysuser set uname='" + uname + "',upass='" + upass + "',tname='" + tname + "',sfid='" + sfid + "',sex='" + sex + "',birth='" + birth + "',tel='" + tel + "',addrs='" + addrs + "',email='" + email + "',filename='" + filename + "' where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/jssysuserxg.jsp?id=" + id + "");
        }
        //jssysuserxg.jsp请求处理结束

        //subjectstj.jsp请求处理开始
        if (ac.equals("subjectstj")) {
            String sno = request.getParameter("sno") == null ? "" : request.getParameter("sno");
            String sname = request.getParameter("sname") == null ? "" : request.getParameter("sname");
            String sections = request.getParameter("sections") == null ? "" : request.getParameter("sections");
            String remo = request.getParameter("remo") == null ? "" : request.getParameter("remo");
            String sql = "insert into subjects(sno,sname,sections,remo " +
                    ")values('" + sno + "','" + sname + "','" + sections + "','" + remo + "')";
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/subjectstj.jsp");
        }
        //subjectstj.jsp请求处理结束

        //subjectsxg.jsp请求处理开始
        if (ac.equals("subjectsxg")) {
            String id = request.getParameter("id");
            String sno = request.getParameter("sno") == null ? "" : request.getParameter("sno");
            String sname = request.getParameter("sname") == null ? "" : request.getParameter("sname");
            String sections = request.getParameter("sections") == null ? "" : request.getParameter("sections");
            String remo = request.getParameter("remo") == null ? "" : request.getParameter("remo");
            String sql = "update subjects set sno='" + sno + "',sname='" + sname + "',sections='" + sections + "',remo='" + remo + "' where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/subjectsxg.jsp?id=" + id + "");
        }
        //subjectsxg.jsp请求处理结束

        //tmixinfotj.jsp请求处理开始
        if (ac.equals("tmixinfotj")) {
            String content = request.getParameter("content") == null ? "" : request.getParameter("content");
            content = content.replaceAll("'", " ");
            String sql = "insert into mixinfo(content " +
                    ")values('" + content + "')";
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/tmixinfotj.jsp");
        }
        //tmixinfotj.jsp请求处理结束

        //tmixinfoxg.jsp请求处理开始
        if (ac.equals("tmixinfoxg")) {
            String id = request.getParameter("id");
            String mtitle = request.getParameter("mtitle") == null ? "" : request.getParameter("mtitle");
            String cotitle = request.getParameter("cotitle") == null ? "" : request.getParameter("cotitle");
            String filename = request.getParameter("filename") == null ? "" : request.getParameter("filename");
            String sql = "update mixinfo set mtitle='" + mtitle + "',cotitle='" + cotitle + "',filename='" + filename + "' where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/tmixinfoxg.jsp?id=" + id + "");
        }
        //tmixinfoxg.jsp请求处理结束

        //messagesxg.jsp请求处理开始
        if (ac.equals("messagesxg")) {
            String id = request.getParameter("id");
            String recont = request.getParameter("recont") == null ? "" : request.getParameter("recont");
            String sql = "update messages set recont='" + recont + "' where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/messagesxg.jsp?id=" + id + "");
        }
        //messagesxg.jsp请求处理结束

        //tresourcestj.jsp请求处理开始
        if (ac.equals("tresourcestj")) {
            String title = request.getParameter("title") == null ? "" : request.getParameter("title");
            String stype = request.getParameter("stype") == null ? "" : request.getParameter("stype");
            String ipush = request.getParameter("ipush") == null ? "" : request.getParameter("ipush");
            String savetime = date;
            String filename = request.getParameter("filename") == null ? "" : request.getParameter("filename");
            String docname2 = request.getParameter("docname2") == null ? "" : request.getParameter("docname2");
            String docname3 = request.getParameter("docname3") == null ? "" : request.getParameter("docname3");
            String content = request.getParameter("content") == null ? "" : request.getParameter("content");
            content = content.replaceAll("'", " ");
            String uname = Info.getUser(request).get("uname").toString();
            String sql = "insert into resources(title,stype,ipush,savetime,filename,docname2,docname3,content,uname " +
                    ")values('" + title + "','" + stype + "','" + ipush + "','" + savetime + "','" + filename + "','" + docname2 + "','" + docname3 + "','" + content + "','" + uname + "')";
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/tresourcestj.jsp");
        }
        //tresourcestj.jsp请求处理结束

        //tresourcesxg.jsp请求处理开始
        if (ac.equals("tresourcesxg")) {
            String id = request.getParameter("id");
            String title = request.getParameter("title") == null ? "" : request.getParameter("title");
            String stype = request.getParameter("stype") == null ? "" : request.getParameter("stype");
            String ipush = request.getParameter("ipush") == null ? "" : request.getParameter("ipush");
            String filename = request.getParameter("filename") == null ? "" : request.getParameter("filename");
            String docname2 = request.getParameter("docname2") == null ? "" : request.getParameter("docname2");
            String docname3 = request.getParameter("docname3") == null ? "" : request.getParameter("docname3");
            String content = request.getParameter("content") == null ? "" : request.getParameter("content");
            content = content.replaceAll("'", " ");
            String sql = "update resources set title='" + title + "',stype='" + stype + "',ipush='" + ipush + "',filename='" + filename + "',docname2='" + docname2 + "',docname3='" + docname3 + "',content='" + content + "' where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/tresourcesxg.jsp?id=" + id + "");
        }
        //tresourcesxg.jsp请求处理结束

        //squestionstj.jsp请求处理开始
        if (ac.equals("squestionstj")) {
            String touname = request.getParameter("touname") == null ? "" : request.getParameter("touname");
            String tounamekey = dao.getID("questions", "touname", "sysuser", "uname~hnoname", touname);
            String subject = request.getParameter("subject") == null ? "" : request.getParameter("subject");
            String subjectkey = dao.getID("questions", "subject", "subjects", "sname~hnoname", subject);
            String title = request.getParameter("title") == null ? "" : request.getParameter("title");
            String savetime = date;
            String filename = request.getParameter("filename") == null ? "" : request.getParameter("filename");
            String uname = Info.getUser(request).get("uname").toString();
            String sql = "insert into questions(touname,tounamekey,subject,subjectkey,title,savetime,filename,uname " +
                    ")values('" + touname + "','" + tounamekey + "','" + subject + "','" + subjectkey + "','" + title + "','" + savetime + "','" + filename + "','" + uname + "')";
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/squestionstj.jsp");
        }
        //squestionstj.jsp请求处理结束

        //squestionsxg.jsp请求处理开始
        if (ac.equals("squestionsxg")) {
            String id = request.getParameter("id");
            String sql = "update questions set where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/squestionsxg.jsp?id=" + id + "");
        }
        //squestionsxg.jsp请求处理结束

        //tquestionsxg.jsp请求处理开始
        if (ac.equals("tquestionsxg")) {
            String id = request.getParameter("id");
            String content = request.getParameter("content") == null ? "" : request.getParameter("content");
            content = content.replaceAll("'", " ");
            String sql = "update questions set content='" + content + "' where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/tquestionsxg.jsp?id=" + id + "");
        }
        //tquestionsxg.jsp请求处理结束

        //hworkstj.jsp请求处理开始
        if (ac.equals("hworkstj")) {
            String subject = request.getParameter("subject") == null ? "" : request.getParameter("subject");
            String subjectkey = dao.getID("hworks", "subject", "subjects", "sname~hnoname", subject);
            String title = request.getParameter("title") == null ? "" : request.getParameter("title");
            String remo = request.getParameter("remo") == null ? "" : request.getParameter("remo");
            String edate = request.getParameter("edate") == null ? "" : request.getParameter("edate");
            String savetime = date;
            String docname = request.getParameter("docname") == null ? "" : request.getParameter("docname");
            String uname = Info.getUser(request).get("uname").toString();
            String tname = Info.getUser(request).get("tname").toString();
            String sql = "insert into hworks(subject,subjectkey,title,remo,edate,savetime,docname,uname,tname " +
                    ")values('" + subject + "','" + subjectkey + "','" + title + "','" + remo + "','" + edate + "','" + savetime + "','" + docname + "','" + uname + "','" + tname + "')";
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/hworkstj.jsp");
        }
        //hworkstj.jsp请求处理结束

        //hworksxg.jsp请求处理开始
        if (ac.equals("hworksxg")) {
            String id = request.getParameter("id");
            String subject = request.getParameter("subject") == null ? "" : request.getParameter("subject");
            String subjectkey = dao.getID("hworks", "subject", "subjects", "sname~hnoname", subject);
            String title = request.getParameter("title") == null ? "" : request.getParameter("title");
            String remo = request.getParameter("remo") == null ? "" : request.getParameter("remo");
            String edate = request.getParameter("edate") == null ? "" : request.getParameter("edate");
            String docname = request.getParameter("docname") == null ? "" : request.getParameter("docname");
            String sql = "update hworks set subject='" + subject + "',subjectkey='" + subjectkey + "',title='" + title + "',remo='" + remo + "',edate='" + edate + "',docname='" + docname + "' where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/hworksxg.jsp?id=" + id + "");
        }
        //hworksxg.jsp请求处理结束

        //chworksxg.jsp请求处理开始
        if (ac.equals("chworksxg")) {
            String id = request.getParameter("id");
            String sql = "update hworks set where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/chworksxg.jsp?id=" + id + "");
        }
        //chworksxg.jsp请求处理结束

        //hworkhandintj.jsp请求处理开始
        if (ac.equals("hworkhandintj")) {
            String savetime = date;
            String docname = request.getParameter("docname") == null ? "" : request.getParameter("docname");
            String id = request.getParameter("id") == null ? "" : request.getParameter("id");
            HashMap mmm = new CommDAO().getmap(id, "hworks");
            String uname = Info.getUser(request).get("uname").toString();
            String tname = Info.getUser(request).get("tname").toString();
            String sql = "insert into hworkhandin(savetime,docname,uname,tname,title,subject,buname,btname,hid " +
                    ")values('" + savetime + "','" + docname + "','" + uname + "','" + tname + "','" + mmm.get("title") + "','" + mmm.get("subject") + "','" + mmm.get("uname") + "','" + mmm.get("tname") + "','" + id + "')";
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/chworkscx.jsp");
        }
        //hworkhandintj.jsp请求处理结束

        //shworkhandinxg.jsp请求处理开始
        if (ac.equals("shworkhandinxg")) {
            String id = request.getParameter("id");
            String docname = request.getParameter("docname") == null ? "" : request.getParameter("docname");
            String sql = "update hworkhandin set docname='" + docname + "' where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/shworkhandinxg.jsp?id=" + id + "");
        }
        //shworkhandinxg.jsp请求处理结束

        //thworkhandinxg.jsp请求处理开始
        if (ac.equals("thworkhandinxg")) {
            String id = request.getParameter("id");
            String score = request.getParameter("score") == null ? "" : request.getParameter("score");
            String remo = request.getParameter("remo") == null ? "" : request.getParameter("remo");
            String docname = request.getParameter("docname") == null ? "" : request.getParameter("docname");
            String sql = "update hworkhandin set score='" + score + "',remo='" + remo + "',docname='" + docname + "' where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/thworkhandinxg.jsp?id=" + id + "");
        }
        //thworkhandinxg.jsp请求处理结束

        //ststj.jsp请求处理开始
        if (ac.equals("ststj")) {
            String stsname = request.getParameter("stsname") == null ? "" : request.getParameter("stsname");
            String sub = request.getParameter("sub") == null ? "" : request.getParameter("sub");
            String subkey = dao.getID("sts", "sub", "subjects", "sname~hnoname", sub);
            String kssj = request.getParameter("kssj") == null ? "" : request.getParameter("kssj");
            String stsids = dao.getCheckBoxValues(request, "stsids");
            String sql = "insert into sts(stsname,sub,subkey,kssj,stsids " +
                    ")values('" + stsname + "','" + sub + "','" + subkey + "','" + kssj + "','" + stsids + "')";
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/ststj.jsp");
        }
        //ststj.jsp请求处理结束

        //stsxg.jsp请求处理开始
        if (ac.equals("stsxg")) {
            String id = request.getParameter("id");
            String stsname = request.getParameter("stsname") == null ? "" : request.getParameter("stsname");
            String sub = request.getParameter("sub") == null ? "" : request.getParameter("sub");
            String subkey = dao.getID("sts", "sub", "subjects", "sname~hnoname", sub);
            String kssj = request.getParameter("kssj") == null ? "" : request.getParameter("kssj");
            String stsids = dao.getCheckBoxValues(request, "stsids");
            String sql = "update sts set stsname='" + stsname + "',sub='" + sub + "',subkey='" + subkey + "',kssj='" + kssj + "',stsids='" + stsids + "' where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/stsxg.jsp?id=" + id + "");
        }
        //stsxg.jsp请求处理结束

        //shitistj.jsp请求处理开始
        if (ac.equals("shitistj")) {
            String subject = request.getParameter("subject") == null ? "" : request.getParameter("subject");
            String subjectkey = dao.getID("shitis", "subject", "subjects", "sname~hnoname", subject);
            String title = request.getParameter("title") == null ? "" : request.getParameter("title");
            String scontent = request.getParameter("scontent") == null ? "" : request.getParameter("scontent");
            String stype = request.getParameter("stype") == null ? "" : request.getParameter("stype");
            String answers = request.getParameter("answers") == null ? "" : request.getParameter("answers");
            String fenzhi = request.getParameter("fenzhi") == null ? "" : request.getParameter("fenzhi");
            String sql = "insert into shitis(subject,subjectkey,title,scontent,stype,answers,fenzhi " +
                    ")values('" + subject + "','" + subjectkey + "','" + title + "','" + scontent + "','" + stype + "','" + answers + "','" + fenzhi + "')";
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/shitistj.jsp");
        }
        //shitistj.jsp请求处理结束

        //shitisxg.jsp请求处理开始
        if (ac.equals("shitisxg")) {
            String id = request.getParameter("id");
            String subject = request.getParameter("subject") == null ? "" : request.getParameter("subject");
            String subjectkey = dao.getID("shitis", "subject", "subjects", "sname~hnoname", subject);
            String title = request.getParameter("title") == null ? "" : request.getParameter("title");
            String scontent = request.getParameter("scontent") == null ? "" : request.getParameter("scontent");
            String stype = request.getParameter("stype") == null ? "" : request.getParameter("stype");
            String answers = request.getParameter("answers") == null ? "" : request.getParameter("answers");
            String fenzhi = request.getParameter("fenzhi") == null ? "" : request.getParameter("fenzhi");
            String sql = "update shitis set subject='" + subject + "',subjectkey='" + subjectkey + "',title='" + title + "',scontent='" + scontent + "',stype='" + stype + "',answers='" + answers + "',fenzhi='" + fenzhi + "' where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/shitisxg.jsp?id=" + id + "");
        }
        //shitisxg.jsp请求处理结束

        //xsstsxg.jsp请求处理开始
        if (ac.equals("xsstsxg")) {
            String id = request.getParameter("id");
            String stsname = request.getParameter("stsname") == null ? "" : request.getParameter("stsname");
            String sub = request.getParameter("sub") == null ? "" : request.getParameter("sub");
            String subkey = dao.getID("sts", "sub", "subjects", "sname~hnoname", sub);
            String kssj = request.getParameter("kssj") == null ? "" : request.getParameter("kssj");
            String stsids = dao.getCheckBoxValues(request, "stsids");
            String sql = "update sts set stsname='" + stsname + "',sub='" + sub + "',subkey='" + subkey + "',kssj='" + kssj + "',stsids='" + stsids + "' where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/xsstsxg.jsp?id=" + id + "");
        }
        //xsstsxg.jsp请求处理结束

        //yxsstsxg.jsp请求处理开始
        if (ac.equals("yxsstsxg")) {
            String id = request.getParameter("id");
            String sql = "update grades set where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/yxsstsxg.jsp?id=" + id + "");
        }
        //yxsstsxg.jsp请求处理结束

        //hworkhandintj2.jsp请求处理开始
        if (ac.equals("hworkhandintj2")) {
            String title = request.getParameter("title") == null ? "" : request.getParameter("title");
            String titlekey = dao.getID("hworkhandin", "title", "hworks", "title~hnoname", title);
            String subject = request.getParameter("subject") == null ? "" : request.getParameter("subject");
            String buname = request.getParameter("buname") == null ? "" : request.getParameter("buname");
            String btname = request.getParameter("btname") == null ? "" : request.getParameter("btname");
            String hid = request.getParameter("hid") == null ? "" : request.getParameter("hid");
            String savetime = date;
            String docname = request.getParameter("docname") == null ? "" : request.getParameter("docname");
            String uname = Info.getUser(request).get("uname").toString();
            String tname = Info.getUser(request).get("tname").toString();
            String sql = "insert into hworkhandin(title,titlekey,subject,buname,btname,hid,savetime,docname,uname,tname " +
                    ")values('" + title + "','" + titlekey + "','" + subject + "','" + buname + "','" + btname + "','" + hid + "','" + savetime + "','" + docname + "','" + uname + "','" + tname + "')";
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/hworkhandintj2.jsp");
        }
        //hworkhandintj2.jsp请求处理结束

        //hworkhandintj3.jsp请求处理开始
        if (ac.equals("hworkhandintj3")) {
            String title = request.getParameter("title") == null ? "" : request.getParameter("title");
            String titlekey = dao.getID("hworkhandin", "title", "hworks", "title~hnoname", title);
            String subject = request.getParameter("subject") == null ? "" : request.getParameter("subject");
            String buname = request.getParameter("buname") == null ? "" : request.getParameter("buname");
            String btname = request.getParameter("btname") == null ? "" : request.getParameter("btname");
            String hid = request.getParameter("hid") == null ? "" : request.getParameter("hid");
            String savetime = date;
            String docname = request.getParameter("docname") == null ? "" : request.getParameter("docname");
            String uname = Info.getUser(request).get("uname").toString();
            String tname = Info.getUser(request).get("tname").toString();
            String sql = "insert into hworkhandin(title,titlekey,subject,buname,btname,hid,savetime,docname,uname,tname " +
                    ")values('" + title + "','" + titlekey + "','" + subject + "','" + buname + "','" + btname + "','" + hid + "','" + savetime + "','" + docname + "','" + uname + "','" + tname + "')";
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/hworkhandintj3.jsp");
        }
        //hworkhandintj3.jsp请求处理结束

        //flisttj.jsp请求处理开始
        if (ac.equals("flisttj")) {
            String memberno = request.getParameter("memberno") == null ? "" : request.getParameter("memberno");
            String tableno = request.getParameter("tableno") == null ? "" : request.getParameter("tableno");
            String frgroupno = request.getParameter("frgroupno");
            String dytablename = request.getParameter("dytablename");
            String dytabdelrows = request.getParameter("dytab_del_rows");
            dao.insertDYTable(dytablename, frgroupno, dytabdelrows, request);
            String price = request.getParameter("price") == null ? "" : request.getParameter("price");
            String savetime = date;
            String sql = "insert into flist(memberno,tableno,frgroupno,food,price,savetime " +
                    ")values('" + memberno + "','" + tableno + "','" + frgroupno + "','dytab-" + dytablename + "','" + price + "','" + savetime + "')";
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/flisttj.jsp");
        }
        //flisttj.jsp请求处理结束

        //flistxg.jsp请求处理开始
        if (ac.equals("flistxg")) {
            String id = request.getParameter("id");
            String memberno = request.getParameter("memberno") == null ? "" : request.getParameter("memberno");
            String tableno = request.getParameter("tableno") == null ? "" : request.getParameter("tableno");
            String frgroupno = request.getParameter("frgroupno");
            String dytablename = request.getParameter("dytablename");
            String dytabdelrows = request.getParameter("dytab_del_rows");
            dao.insertDYTable(dytablename, frgroupno, dytabdelrows, request);
            String price = request.getParameter("price") == null ? "" : request.getParameter("price");
            String sql = "update flist set memberno='" + memberno + "',tableno='" + tableno + "',frgroupno='" + frgroupno + "',food='dytab-" + dytablename + "',price='" + price + "' where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/flistxg.jsp?id=" + id + "");
        }
        //flistxg.jsp请求处理结束

        //examstesttj.jsp请求处理开始
        if (ac.equals("examstesttj")) {
            String examname = request.getParameter("examname") == null ? "" : request.getParameter("examname");
            String tname = request.getParameter("tname") == null ? "" : request.getParameter("tname");
            String tnamekey = dao.getID("examstest", "tname", "sysuser", "uname~hnoname", tname);
            String fyear = request.getParameter("fyear") == null ? "" : request.getParameter("fyear");
            String mins = request.getParameter("mins") == null ? "" : request.getParameter("mins");
            String frgroupno = request.getParameter("frgroupno");
            String dytablename = request.getParameter("dytablename");
            String dytabdelrows = request.getParameter("dytab_del_rows");
            dao.insertDYTable(dytablename, frgroupno, dytabdelrows, request);
            String sql = "insert into examstest(examname,tname,tnamekey,fyear,mins,frgroupno,sts " +
                    ")values('" + examname + "','" + tname + "','" + tnamekey + "','" + fyear + "','" + mins + "','" + frgroupno + "','dytab-" + dytablename + "')";
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/examstesttj.jsp");
        }
        //examstesttj.jsp请求处理结束

        //examstestxg.jsp请求处理开始
        if (ac.equals("examstestxg")) {
            String id = request.getParameter("id");
            String examname = request.getParameter("examname") == null ? "" : request.getParameter("examname");
            String tname = request.getParameter("tname") == null ? "" : request.getParameter("tname");
            String tnamekey = dao.getID("examstest", "tname", "sysuser", "uname~hnoname", tname);
            String fyear = request.getParameter("fyear") == null ? "" : request.getParameter("fyear");
            String mins = request.getParameter("mins") == null ? "" : request.getParameter("mins");
            String frgroupno = request.getParameter("frgroupno");
            String dytablename = request.getParameter("dytablename");
            String dytabdelrows = request.getParameter("dytab_del_rows");
            dao.insertDYTable(dytablename, frgroupno, dytabdelrows, request);
            String sql = "update examstest set examname='" + examname + "',tname='" + tname + "',tnamekey='" + tnamekey + "',fyear='" + fyear + "',mins='" + mins + "',frgroupno='" + frgroupno + "',sts='dytab-" + dytablename + "' where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/examstestxg.jsp?id=" + id + "");
        }
        //examstestxg.jsp请求处理结束

        //uapplystj.jsp请求处理开始
        if (ac.equals("uapplystj")) {
            String touname = request.getParameter("touname") == null ? "" : request.getParameter("touname");
            String tounamekey = dao.getID("applys", "touname", "sysuser", "uname~hnoname", touname);
            String pdate = request.getParameter("pdate") == null ? "" : request.getParameter("pdate");
            String subject = request.getParameter("subject") == null ? "" : request.getParameter("subject");
            String subjectkey = dao.getID("applys", "subject", "subjects", "sname~hnoname", subject);
            String uname = Info.getUser(request).get("uname").toString();
            String tname = Info.getUser(request).get("tname").toString();
            String status = "申请中";
            String sql = "insert into applys(touname,tounamekey,pdate,subject,subjectkey,uname,tname,status " +
                    ")values('" + touname + "','" + tounamekey + "','" + pdate + "','" + subject + "','" + subjectkey + "','" + uname + "','" + tname + "','" + status + "')";
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/uapplystj.jsp");
        }
        //uapplystj.jsp请求处理结束

        //uapplysxg.jsp请求处理开始
        if (ac.equals("uapplysxg")) {
            String id = request.getParameter("id");
            String touname = request.getParameter("touname") == null ? "" : request.getParameter("touname");
            String tounamekey = dao.getID("applys", "touname", "sysuser", "uname~hnoname", touname);
            String pdate = request.getParameter("pdate") == null ? "" : request.getParameter("pdate");
            String subject = request.getParameter("subject") == null ? "" : request.getParameter("subject");
            String subjectkey = dao.getID("applys", "subject", "subjects", "sname~hnoname", subject);
            String sql = "update applys set touname='" + touname + "',tounamekey='" + tounamekey + "',pdate='" + pdate + "',subject='" + subject + "',subjectkey='" + subjectkey + "' where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/uapplysxg.jsp?id=" + id + "");
        }
        //uapplysxg.jsp请求处理结束

        //salstj.jsp请求处理开始
        if (ac.equals("salstj")) {
            String uname = request.getParameter("uname") == null ? "" : request.getParameter("uname");
            String unamekey = dao.getID("sals", "uname", "sysuser", "uname~hnoname", uname);
            String pmonth = request.getParameter("pmonth") == null ? "" : request.getParameter("pmonth");
            String basesal = request.getParameter("basesal") == null ? "" : request.getParameter("basesal");
            String ysal = request.getParameter("ysal") == null ? "" : request.getParameter("ysal");
            String tsal = request.getParameter("tsal") == null ? "" : request.getParameter("tsal");
            String bsal = request.getParameter("bsal") == null ? "" : request.getParameter("bsal");
            String sf = request.getParameter("sf") == null ? "" : request.getParameter("sf");
            String sql = "insert into sals(uname,unamekey,pmonth,basesal,ysal,tsal,bsal,sf " +
                    ")values('" + uname + "','" + unamekey + "','" + pmonth + "','" + basesal + "','" + ysal + "','" + tsal + "','" + bsal + "','" + sf + "')";
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/salstj.jsp");
        }
        //salstj.jsp请求处理结束

        //salsxg.jsp请求处理开始
        if (ac.equals("salsxg")) {
            String id = request.getParameter("id");
            String uname = request.getParameter("uname") == null ? "" : request.getParameter("uname");
            String unamekey = dao.getID("sals", "uname", "sysuser", "uname~hnoname", uname);
            String pmonth = request.getParameter("pmonth") == null ? "" : request.getParameter("pmonth");
            String basesal = request.getParameter("basesal") == null ? "" : request.getParameter("basesal");
            String ysal = request.getParameter("ysal") == null ? "" : request.getParameter("ysal");
            String tsal = request.getParameter("tsal") == null ? "" : request.getParameter("tsal");
            String bsal = request.getParameter("bsal") == null ? "" : request.getParameter("bsal");
            String sf = request.getParameter("sf") == null ? "" : request.getParameter("sf");
            String sql = "update sals set uname='" + uname + "',unamekey='" + unamekey + "',pmonth='" + pmonth + "',basesal='" + basesal + "',ysal='" + ysal + "',tsal='" + tsal + "',bsal='" + bsal + "',sf='" + sf + "' where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/salsxg.jsp?id=" + id + "");
        }
        //salsxg.jsp请求处理结束

        //resourcestj.jsp请求处理开始
        if (ac.equals("resourcestj")) {
            String title = request.getParameter("title") == null ? "" : request.getParameter("title");
            String stype = request.getParameter("stype") == null ? "" : request.getParameter("stype");
            String ipush = request.getParameter("ipush") == null ? "" : request.getParameter("ipush");
            String savetime = date;
            String filename = request.getParameter("filename") == null ? "" : request.getParameter("filename");
            String content = request.getParameter("content") == null ? "" : request.getParameter("content");
            content = content.replaceAll("'", " ");
            String uname = Info.getUser(request).get("uname").toString();
            String sql = "insert into resources(title,stype,ipush,savetime,filename,content,uname " +
                    ")values('" + title + "','" + stype + "','" + ipush + "','" + savetime + "','" + filename + "','" + content + "','" + uname + "')";
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/resourcestj.jsp");
        }
        //resourcestj.jsp请求处理结束

        //resourcesxg.jsp请求处理开始
        if (ac.equals("resourcesxg")) {
            String id = request.getParameter("id");
            String title = request.getParameter("title") == null ? "" : request.getParameter("title");
            String stype = request.getParameter("stype") == null ? "" : request.getParameter("stype");
            String ipush = request.getParameter("ipush") == null ? "" : request.getParameter("ipush");
            String filename = request.getParameter("filename") == null ? "" : request.getParameter("filename");
            String content = request.getParameter("content") == null ? "" : request.getParameter("content");
            content = content.replaceAll("'", " ");
            String sql = "update resources set title='" + title + "',stype='" + stype + "',ipush='" + ipush + "',filename='" + filename + "',content='" + content + "' where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/resourcesxg.jsp?id=" + id + "");
        }
        //resourcesxg.jsp请求处理结束

        //xresourcestj.jsp请求处理开始
        if (ac.equals("xresourcestj")) {
            String title = request.getParameter("title") == null ? "" : request.getParameter("title");
            String stype = request.getParameter("stype") == null ? "" : request.getParameter("stype");
            String ipush = request.getParameter("ipush") == null ? "" : request.getParameter("ipush");
            String savetime = date;
            String filename = request.getParameter("filename") == null ? "" : request.getParameter("filename");
            String content = request.getParameter("content") == null ? "" : request.getParameter("content");
            content = content.replaceAll("'", " ");
            String uname = Info.getUser(request).get("uname").toString();
            String sql = "insert into resources(title,stype,ipush,savetime,filename,content,uname " +
                    ")values('" + title + "','" + stype + "','" + ipush + "','" + savetime + "','" + filename + "','" + content + "','" + uname + "')";
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/xresourcestj.jsp");
        }
        //xresourcestj.jsp请求处理结束

        //xresourcesxg.jsp请求处理开始
        if (ac.equals("xresourcesxg")) {
            String id = request.getParameter("id");
            String title = request.getParameter("title") == null ? "" : request.getParameter("title");
            String stype = request.getParameter("stype") == null ? "" : request.getParameter("stype");
            String ipush = request.getParameter("ipush") == null ? "" : request.getParameter("ipush");
            String filename = request.getParameter("filename") == null ? "" : request.getParameter("filename");
            String content = request.getParameter("content") == null ? "" : request.getParameter("content");
            content = content.replaceAll("'", " ");
            String sql = "update resources set title='" + title + "',stype='" + stype + "',ipush='" + ipush + "',filename='" + filename + "',content='" + content + "' where id=" + id;
            dao.commOper(sql);
            session.setAttribute("suc", "suc");
            response.sendRedirect("/wallpaper/admin/xresourcesxg.jsp?id=" + id + "");
        }
        //xresourcesxg.jsp请求处理结束

//--业务层代码块结束--
        dao.close();
        out.flush();
        out.close();
    }


    public void init() throws ServletException {
        // Put your code here
    }


}
